package com.pkk.blny.web.controller.api;

import com.pkk.blny.model.domain.User;
import com.pkk.blny.model.dto.JsonResult;
import com.pkk.blny.model.enums.ResponseStatusEnum;
import com.pkk.blny.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <pre>
 *     用户API
 * </pre>
 *
 * @author : RYAN0UP
 * @date : 2018/6/6
 */
@CrossOrigin
@RestController
@RequestMapping(value = "/api/user")
public class ApiUserController {

  @Autowired
  private UserService userService;

  /**
   * 获取博主信息
   *
   * <p>
   * result json:
   * <pre>
   * {
   *     "code": 200,
   *     "msg": "OK",
   *     "result": {
   *         "userId": ,
   *         "userDisplayName": "",
   *         "userEmail": "",
   *         "userAvatar": "",
   *         "userDesc": ""
   *     }
   * }
   *     </pre>
   * </p>
   *
   * @return JsonResult
   */
  @GetMapping
  public JsonResult user() {
    User user = userService.findUser();
    return new JsonResult(ResponseStatusEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), user);
  }
}
